package ai.zixing.memento01;

public class Client {
    public static void main(String[] args) {
        // 创建发起人对象
        Originator originator = new Originator();
        originator.setId("1");
        originator.setName("子星");
        originator.setPhone("13512341234");
        System.out.println("=============" + originator);

        // 创建负责人对象
        Caretaker caretaker = new Caretaker();
        caretaker.setMemento(originator.createMemento());

        // 修改操作
        originator.setName("星星");
        System.out.println("==========" + originator);

        // 从负责人对象中恢复状态
        originator.restore(caretaker.getMemento());
        System.out.println("==========" + originator);
    }
}
